﻿
using Kitware.VTK;
using NuiDicomPlayer.Controls;
using NuiDicomPlayer.Controls.Elements;
using NuiDicomPlayer.Vtk;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Timers;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Threading.Tasks;
using Biomedica.Graphics;

namespace NuiDicomPlayer.Subviews
{
    /// <summary>
    /// Interaction logic for DicomPlayer.xaml
    /// </summary>
    public partial class DicomPlayer : SubviewBase
    {

        private delegate void OnPerformVoiceCommand(String Command);
        public Vector2 RefLocation { get; set; }

        #region VtkProps

        public int Slice
        {
            set
            { 
                main_viewer.SetSlice(Convert.ToInt32(value));
                SliceNumber.SetInput(value.ToString());
            }
            get { return main_viewer.GetSlice(); }
        }
        public double Brightness
        {
            get
            {
                return Convert.ToInt32(main_viewer.GetColorLevel());
            }
            set
            {
                if (value > 0 && value < 3000)
                {
                    main_viewer.SetColorLevel(value);
                    main_viewer.GetRenderWindow().Render();
                    UpdateBrightnessText(main_viewer.GetColorLevel());
                }

            }
        }
        public double Contrast
        {
            get
            {
                return Convert.ToInt32(main_viewer.GetColorWindow());
            }
            set
            {
                if (value > 0 && value < 3000)
                {
                    UpdateContrastText(main_viewer.GetColorWindow());
                    main_viewer.SetColorWindow(value);
                    main_viewer.GetRenderWindow().Render();
                    
                }

            }

        }
        public String VoiceCommandText
        {

            set
            {
                voiceCommand_Text.SetInput(value);
                if (!value.Equals("")) txtTimer.Enabled = true;
            }
        }
        public int MAX { get { return main_viewer.GetSliceMax(); } }
        public String CurrentPlane { set { PlaneAnotation.SetInput(value); } }
        private void UpdateBrightnessText(double value)
        {
            try
            {
                int val = Convert.ToInt32(((3000-value) / 3000) * 10);
                if(val>=0 && val<3000)
                {
                StringBuilder b = new StringBuilder();
                for (int i = 0; i < val; i++) b.Append("|");
                
                brightness.SetInput("Brightness    "+b.ToString());
                }
            }
            catch (Exception err)
            {
            }
        }
        private void UpdateContrastText(double value)
        {
            try
            {
                int val = Convert.ToInt32(((3000-value) / 3000) * 10);
                if (val >= 0 && val < 3000)
                {
                    StringBuilder b = new StringBuilder();
                    for (int i = 0; i < val; i++) b.Append("|");
                    contrast.SetInput("Contrast :     "+b.ToString());
                }
            }
            catch (Exception err)
            {
            }
        }
        #endregion
        #region events
        public event EventHandler OnQuitBtnPressed;
        public event EventHandler OnNewDicomSelect;
        public event EventHandler OnDicomInformation;
        public event EventHandler OnPataintInformation;
        public event EventHandler OnHelpFired;
        #endregion
        #region VTK
        public int Crt_slice { set; get; } // the current selected slice
        public DicomImageInfo DicomInfo { set; get; } // theionn vtk dicom informat

        public vtkImageViewer2 main_viewer { set; get; }
        public vtkDICOMImageReader dicom_reader { set; get; }
        public vtkImageReslice resclicer { set; get; }

        /// <summary>
        /// Vtk Text Anotation
        /// </summary>
        private vtkTextActor PlaneAnotation, SliceNumber, brightness, contrast, lefthandmouse, righthandmouse, voiceCommand_Text;


        double xMin, yMin, zMin;
        double xMax, yMax, zMax;
        double xSpaceing, ySpaceing, zSpaceing;
        double x0, y0, z0;
        double centerX, centery, centerz;
        double[] axial;
        double[] coronal;
        double[] sagital;
        int[] DICOMExtent;
        private double zoomFactor = 1;
        private double B_crnt_value = 255;
        private bool FileIsloaded;
        private string VTKMode;
        private bool IsPlaying;
        public int numberOfSlices { set; get; }
        #endregion
      

        Timer txtTimer = new Timer(1000);
        private Biomedica.Graphics.Vector4 VtkBounds;
        void txtTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            VoiceCommandText = "";
            ((Timer)sender).Enabled = false;
        }
       
        public DicomPlayer()
        {
            InitializeComponent();
            newDicomFile.RootPath = System.IO.Directory.GetCurrentDirectory();
            txtTimer.Elapsed += txtTimer_Elapsed;


            main_viewer = vtkImageViewer2.New();
            dicom_reader = vtkDICOMImageReader.New();
            resclicer = vtkImageReslice.New();

            // text Anotation

            PlaneAnotation = vtkTextActor.New();
            PlaneAnotation.GetTextProperty().SetColor(1, 1, 0.5);
            PlaneAnotation.GetTextProperty().SetFontSize(18);
            PlaneAnotation.SetPosition(700, 18);
            CurrentPlane = "NA";

            SliceNumber = vtkTextActor.New();
            SliceNumber.GetTextProperty().SetColor(1, 1, 0.5);
            SliceNumber.GetTextProperty().SetFontSize(18);
            SliceNumber.SetPosition(0, 18);
            SliceNumber.SetInput("##");

            brightness = vtkTextActor.New();
            brightness.GetTextProperty().SetColor(1, 1, 0.5);
            brightness.SetPosition(10, 50);
            brightness.GetTextProperty().SetFontSize(18);
            brightness.SetInput("_ _ _ _ _ _ _ _ _ _");

            contrast = vtkTextActor.New();
            contrast.GetTextProperty().SetColor(1, 1, 0.5);
            contrast.SetPosition(10, 32);
            contrast.GetTextProperty().SetFontSize(18);
            contrast.SetInput("_ _ _ _ _ _ _ _ _ _");


            this.voiceCommand_Text = vtkTextActor.New();
            voiceCommand_Text.GetTextProperty().SetColor(1, 0.5, 0.5);
            voiceCommand_Text.SetPosition(500, 0);
            voiceCommand_Text.SetInput("---------------------------------------");

            lefthandmouse = vtkTextActor.New();
            righthandmouse = vtkTextActor.New();
            
            righthandmouse.GetTextProperty().SetColor(1, 0.5, 0.5);
            righthandmouse.SetPosition(-1, -1);
            righthandmouse.GetTextProperty().SetFontSize(22);
            righthandmouse.SetInput("+");


           


            main_viewer.GetRenderer().AddViewProp(PlaneAnotation);
            main_viewer.GetRenderer().AddViewProp(SliceNumber);
            main_viewer.GetRenderer().AddViewProp(brightness);
            main_viewer.GetRenderer().AddViewProp(contrast);
            //main_viewer.GetRenderer().AddViewProp(righthandmouse);
           // main_viewer.GetRenderer().AddViewProp(voiceCommand_Text);
            //

            resclicer.SetInputConnection(dicom_reader.GetOutputPort());
            main_viewer.SetInput(resclicer.GetOutput());
            zoomFactor = 1;
            FileIsloaded = false;

            //dicom_reader.SetDirectoryName("");
            dicom_reader.SetDebug(0);
           

            

        }
        #region Nui Action
      
        private void increasebtn_OnHandFiredEvent_1(object sender, EventArgs e)
        {
            if (FileIsloaded)
                switch (VTKMode)
                {
                    case "A":
                        Switch2Axial();
                        Slice++;
                        break;
                    case "C":
                        Switch2Coronal();
                        Slice++;
                        break;
                    case "S":
                        Switch2Sagital();
                        Slice++;
                        break;
                    case "B":
                        Brightness -= 10;
                        break;
                    case "T":
                        Contrast -= 10;
                        break;
                    case "Z":
                        ZoomIn();
                        break;
                    case "PH":
                        PanRight();
                        break;
                    case "PV":
                        PanDown();
                        break;
                }


        }
        private void decreasebtn_OnHandFiredEvent_1(object sender, EventArgs e)
        {
            if (FileIsloaded)
                switch (VTKMode)
                {
                    case "A":
                        Switch2Axial();
                        Slice--;
                        break;
                    case "C":
                        Switch2Coronal();
                        Slice--;
                        break;
                    case "S":
                        Switch2Sagital();
                        Slice--;
                        break;
                    case "B":
                        Brightness += 10;
                        break;
                    case "T":
                        Contrast += 10;
                        break;
                    case "Z":
                        ZoomOut();
                        break;
                    case "PH":
                        PanLeft();
                        break;
                    case "PV":
                        PanUp();
                        break;
                }


        }
        internal void ShowPlayer(bool vis)
        {
            if (vis) wfh.Visibility = Visibility.Visible;
            else wfh.Visibility = Visibility.Collapsed;
        }
        private void quitBtn_OnHandFiredEvent_1(object sender, EventArgs e)
        {
            
            ShowPlayer(false);
            this.OnQuitBtnPressed(this, new EventArgs());
            
        }
        private void newdicomBtn_OnHandFiredEvent_1(object sender, EventArgs e)
        {
            ShowPlayer(false);
            newDicomFile.ShowView();

          if (OnNewDicomSelect != null) this.OnNewDicomSelect(this, new EventArgs());
        }
        private void dicominfoBtn_OnHandFiredEvent_1(object sender, EventArgs e)
        {
            if (!newDicomFile.FileName.Equals(""))
            {
                ShowPlayer(false);
                this.pataintinfos.UpdatePatainInformations(DicomInfo);
                this.pataintinfos.ShowView();


                if (OnDicomInformation != null) this.OnDicomInformation(this, new EventArgs());
            }
        }
        private void patiantinfoinfoBtn_OnHandFiredEvent_1(object sender, EventArgs e)
        {

            if (OnPataintInformation != null) this.OnPataintInformation(this, new EventArgs());
        }
        private void newDicomFile_OnViewDisappear_1(object sender, EventArgs e)
        {
            if (((NewDicomFile)sender).WindowResult==DialogResults.OK)
            {
               
                this.ShowPlayer(true);
                main_viewer.SetRenderWindow(_renderControl.RenderWindow);
                LoadDICOM(newDicomFile.FileName);
                Render();
            } 
            App.ActiveWindow = this;
        }
        #endregion
        #region Dicom Functionality
        ////////////////////////////////////////////////////////////////////////////////
        //
        // Dicom Functionality
        public void LoadDICOM(string DicomDir)
        {

            DicomInfo = new DicomImageInfo();
            DicomInfo.DicomFolderName = DicomDir;
            dicom_reader.SetDirectoryName(DicomDir);
            dicom_reader.Update();
            DICOMExtent = dicom_reader.GetOutput().GetWholeExtent();
            double[] spaceing = dicom_reader.GetOutput().GetSpacing();
            double[] origen = dicom_reader.GetOutput().GetOrigin();
            xMin = DICOMExtent[0];
            xMax = DicomInfo.TotalSagetalSlice = DICOMExtent[1];
            yMin = DICOMExtent[2];
            yMax = DicomInfo.TotalAxialSlice = DICOMExtent[3];
            zMin = DICOMExtent[4];
            zMax = DicomInfo.TotalCoronalSlice = DICOMExtent[5];
            xSpaceing = DicomInfo.XSpaceing = spaceing[0];
            ySpaceing = DicomInfo.YSpaceing = spaceing[1];
            zSpaceing = DicomInfo.ZSpaceing = spaceing[2];
            x0 = DicomInfo.XCenter = origen[0];
            y0 = DicomInfo.YCenter = origen[1];
            z0 = DicomInfo.ZCenter = origen[2];
          
            DicomInfo.ColorLevel = main_viewer.GetColorLevel();
            DicomInfo.ColorWindow = main_viewer.GetColorWindow();
            DicomInfo.StudyID = dicom_reader.GetStudyID();
            DicomInfo.StudyUID = dicom_reader.GetStudyUID();
            DicomInfo.PataintId = dicom_reader.GetPatientName();
            DicomInfo.ImageOr = dicom_reader.GetImageOrientationPatient();
            DicomInfo.ImagePostion = dicom_reader.GetImagePositionPatient();
            DicomInfo.GantryAngle = dicom_reader.GetGantryAngle();
            DicomInfo.TransfearSyntaxID = dicom_reader.GetTransferSyntaxUID();
            Brightness = 3000;
            Contrast = 1000;
            Switch2Axial();
            Slice = 1;
            FileIsloaded = true;
            VTKMode = "A";
        }
        public void Render()
        {
            _renderControl.RenderWindow.SetDebug(0);
            dicom_reader.DebugOff();
            main_viewer.GetRenderer().GetActiveCamera().ComputeViewPlaneNormal();
            if(dicom_reader.GetDirectoryName()!="")
            main_viewer.GetRenderWindow().Render();
        }
        public void Switch2Axial()
        {
            main_viewer.SetSliceOrientationToXY();
            CurrentPlane = "A";
        }
        public void Switch2Sagital()
        {
            resclicer.SetResliceAxesDirectionCosines(1, 0, 0, 0, -1, 0, 0, 0, -1);
            main_viewer.SetSliceOrientationToXZ();
            CurrentPlane = "S";

        }
        public void Switch2Coronal()
        {
            resclicer.SetResliceAxesDirectionCosines(1, 0, 0, 0, -1, 0, 0, 0, -1);
            main_viewer.SetSliceOrientationToYZ();
            CurrentPlane = "C";
        }
        public void ZoomIn()
        {
            main_viewer.GetRenderer().GetActiveCamera().Zoom(1.01);
            _renderControl.RenderWindow.Render();
        }
        public void ZoomOut()
        {
            main_viewer.GetRenderer().GetActiveCamera().Zoom(0.99);
           _renderControl.RenderWindow.Render();
        }
        public void ZoomAll()
        {

            main_viewer.GetRenderer().GetActiveCamera().Zoom(1);
            _renderControl.RenderWindow.Render();

        }
        public void ZoomFactor(double DiagonalLength)
        {
            if (DiagonalLength > 0 && DiagonalLength < 2)
            {
                main_viewer.GetRenderWindow().GetRenderers().GetFirstRenderer().GetActiveCamera().Zoom(DiagonalLength);
            }
        }
        private void btnZoomAll_OnHandFiredEvent_1(object sender, EventArgs e)
        {
            ZoomAll();
        }
        private void resetBri_OnHandFiredEvent_1(object sender, EventArgs e)
        {
            Brightness = 3000;
        }
        private void resetContrastAllbtn_OnHandFiredEvent_1(object sender, EventArgs e)
        {
            Contrast = 1000;

        }
        private void SubviewBase_Loaded_1(object sender, RoutedEventArgs e)
        {
               ShowPlayer(true);
               if (dicom_reader.GetDirectoryName()!=null)
               {
                   _renderControl.RenderWindow.AddRenderer(main_viewer.GetRenderer());
                   main_viewer.SetRenderWindow(_renderControl.RenderWindow);

                 

               }
               ShowPlayer(false);
             
        }
        private void PanUp()
        {
            double[] pos = main_viewer.GetRenderer().GetActiveCamera().GetPosition();
            double[] fpos = main_viewer.GetRenderer().GetActiveCamera().GetFocalPoint();
            switch (PlaneAnotation.GetInput())
            {
                case("A"):
                     main_viewer.GetRenderer().GetActiveCamera().SetPosition(pos[0], pos[1] + 1, pos[2]);
            main_viewer.GetRenderer().GetActiveCamera().SetFocalPoint(fpos[0], fpos[1] + 1, fpos[2]);

                    break;
                case("C"):
                     main_viewer.GetRenderer().GetActiveCamera().SetPosition(pos[0], pos[1] , pos[2]+ 1);
                    main_viewer.GetRenderer().GetActiveCamera().SetFocalPoint(fpos[0], fpos[1] , fpos[2]+ 1);

                    break;
                case("S"):
                    main_viewer.GetRenderer().GetActiveCamera().SetPosition(pos[0], pos[1] , pos[2] + 1);
                    main_viewer.GetRenderer().GetActiveCamera().SetFocalPoint(fpos[0], fpos[1] , fpos[2] + 1);

                    break;
            }
          

            _renderControl.RenderWindow.Render();
        }
        private void PanRight()
        {
            double[] pos = main_viewer.GetRenderer().GetActiveCamera().GetPosition();
            double[] fpos = main_viewer.GetRenderer().GetActiveCamera().GetFocalPoint();
            switch (PlaneAnotation.GetInput())
            {
                case ("A"):
                    main_viewer.GetRenderer().GetActiveCamera().SetPosition(pos[0]+1, pos[1] , pos[2]);
                    main_viewer.GetRenderer().GetActiveCamera().SetFocalPoint(fpos[0]+1, fpos[1] , fpos[2]);

                    break;
                case ("C"):
                    main_viewer.GetRenderer().GetActiveCamera().SetPosition(pos[0], pos[1] + 1, pos[2]);
                    main_viewer.GetRenderer().GetActiveCamera().SetFocalPoint(fpos[0], fpos[1]+ 1 , fpos[2]);

                    break;
                case ("S"):
                    main_viewer.GetRenderer().GetActiveCamera().SetPosition(pos[0]+ 1, pos[1] , pos[2]);
                    main_viewer.GetRenderer().GetActiveCamera().SetFocalPoint(fpos[0]+ 1, fpos[1] , fpos[2]);

                    break;
            }

            _renderControl.RenderWindow.Render();
        }
        private void PanDown()
        {
            double[] pos = main_viewer.GetRenderer().GetActiveCamera().GetPosition();
            double[] fpos = main_viewer.GetRenderer().GetActiveCamera().GetFocalPoint();

            switch (PlaneAnotation.GetInput())
            {
                case ("A"):
                    main_viewer.GetRenderer().GetActiveCamera().SetPosition(pos[0], pos[1] - 1, pos[2]);
                    main_viewer.GetRenderer().GetActiveCamera().SetFocalPoint(fpos[0], fpos[1] - 1, fpos[2]);

                    break;
                case ("C"):
                    main_viewer.GetRenderer().GetActiveCamera().SetPosition(pos[0], pos[1] , pos[2]- 1);
                    main_viewer.GetRenderer().GetActiveCamera().SetFocalPoint(fpos[0], fpos[1] , fpos[2]- 1);

                    break;
                case ("S"):
                    main_viewer.GetRenderer().GetActiveCamera().SetPosition(pos[0], pos[1] , pos[2] - 1);
                    main_viewer.GetRenderer().GetActiveCamera().SetFocalPoint(fpos[0], fpos[1] , fpos[2] - 1);

                    break;
            }

            _renderControl.RenderWindow.Render();
        }
        private void PanLeft()
        {
            double[] pos = main_viewer.GetRenderer().GetActiveCamera().GetPosition();
            double[] fpos = main_viewer.GetRenderer().GetActiveCamera().GetFocalPoint();

            switch (PlaneAnotation.GetInput())
            {
                case ("A"):
                    main_viewer.GetRenderer().GetActiveCamera().SetPosition(pos[0]-1, pos[1], pos[2]);
                    main_viewer.GetRenderer().GetActiveCamera().SetFocalPoint(fpos[0]-1, fpos[1] , fpos[2]);

                    break;
                case ("C"):
                    main_viewer.GetRenderer().GetActiveCamera().SetPosition(pos[0], pos[1]- 1 , pos[2]);
                    main_viewer.GetRenderer().GetActiveCamera().SetFocalPoint(fpos[0], fpos[1]- 1 , fpos[2]);

                    break;
                case ("S"):
                    main_viewer.GetRenderer().GetActiveCamera().SetPosition(pos[0]- 1, pos[1] , pos[2]);
                    main_viewer.GetRenderer().GetActiveCamera().SetFocalPoint(fpos[0]-1, fpos[1] , fpos[2]);

                    break;
            }

            _renderControl.RenderWindow.Render();

        }
        
        public void LoagEvent(String e)
        {
            Label l = new Label();
            l.Content = e;
            logger.Items.Add(l);
            logger.SelectedItem=l;
        }
        public void ExecuteVTKTask(object sender, EventArgs e)
        {
            VTKMode = (string)((NuiControl)sender).Tag;
            ModAnotation.Content = VTKMode;
            SetReferanceSkeleton();
            switch (VTKMode)
            {
                case "A":
                    Switch2Axial();
                    break;
                case "C":
                    Switch2Coronal();
                    break;
                case "S":
                    Switch2Sagital();
                    break;
            }
            

        }

        private void SetReferanceSkeleton()
        {
            this.RefLocation = App.SubActiveMouseVector;
        }
        public void InfoWindowDiappear(object sender, EventArgs e)
        {
            App.ActiveWindow = this;
            ShowPlayer(true);
        }
        public void LoadNewDicomFile()
        {
            newdicomBtn_OnHandFiredEvent_1(this, new EventArgs());
        }


        Timer t = new Timer(50);
        private bool Playingforword;
        private bool nuilessmood;


        private void DoPlayerCommand(string ev)
        {
            if (Playingforword) Slice++;
            else Slice--;
        }
   
        public void PlaySlice(bool playingforword)
        {
            this.Playingforword = playingforword;
            t.Elapsed += t_Elapsed;
            t.Start();
           
            
        }

        void t_Elapsed(object sender, ElapsedEventArgs e)
        {
            this.Dispatcher.Invoke(new OnPerformVoiceCommand(DoPlayerCommand), "");
        }
        public void PausePlaying()
        {
            t.Stop();
        }
        public void RestBrightness()
        {
            resetBri_OnHandFiredEvent_1(this, new EventArgs());
        }
        public void ResetContrast()
        {
            resetContrastAllbtn_OnHandFiredEvent_1(this, new EventArgs());
        }
        public void ShowPataintInformation()
        {
            patiantinfoinfoBtn_OnHandFiredEvent_1(this,new EventArgs());
        }
        public void SetVTKPointers()
        {
            Point p = App.ActiveMouse.Location;

            Biomedica.Graphics.Vector4 v4 = Biomedica.Graphics.Vector4.Zero;
            v4.Left = (float)wfh.TransformToAncestor(this).Transform(new Point(0, 0)).X;
            v4.Top = (float)wfh.TransformToAncestor(this).Transform(new Point(0, 0)).Y;
            v4.Right = (float)wfh.ActualWidth + v4.Left;
            v4.Buttom = (float)wfh.ActualHeight + v4.Top;
            VtkBounds = v4;

            
         
                double dx = (App.ActiveMouse.Location.X / (this.VtkBounds.Right - this.VtkBounds.Left)) * this._renderControl.Width;
                double dy = (App.ActiveMouse.Location.Y / (this.VtkBounds.Buttom - this.VtkBounds.Top)) * this._renderControl.Height;
               // righthandmouse.SetPosition(dx - this._renderControl.Width, this._renderControl.Height -dy);
               // righthandmouse.SetPosition(300, 300);
               // main_viewer.GetRenderWindow().Render();
               
        }
        /// <summary>
        /// Perform any Action relate to hand
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void PerformActionWhenInside(object sender, EventArgs e)
        {
            VTKMode = (string)((NuiControl)sender).Tag;
            nuilessmood = true;
        }
        internal void ClosePipeline()
        {
            main_viewer.Dispose();
            dicom_reader.Dispose();
        }
        #endregion
        #region Speech

        private void PerformVoiceCommand(string voicecommand)
        {
            switch (voicecommand)
            {
                case ("kinect load new file"):
                    this.Dispatcher.Invoke(new EventHandler(newdicomBtn_OnHandFiredEvent_1), this, new EventArgs());
                    break;
                case ("kinect quit"):
                    this.Dispatcher.Invoke(new EventHandler(quitBtn_OnHandFiredEvent_1), this, new EventArgs());
                    break;


                case ("kinect show record "):
                    this.Dispatcher.Invoke(new EventHandler(dicominfoBtn_OnHandFiredEvent_1), this, new EventArgs());
                    break;
                case ("kinect close"):
                    this.Dispatcher.Invoke(new EventHandler(quitBtn_OnHandFiredEvent_1), this, new EventArgs());
                    break;
                case ("kinect show axial"):
                    Switch2Axial();
                    break;
                case ("kinect show coronal"):
                    Switch2Coronal();
                    break;
                case ("kinect show sagital"):
                    Switch2Sagital();
                    break;
                case ("kinect reset brightness"):
                    RestBrightness();
                    break;
                case ("kinect reset contrast"):
                    ResetContrast();
                    break;
                case ("kinect zoom all"):
                    ZoomAll();
                    break;
            }
        }

        internal override void DoSpeechCommand(System.Speech.Recognition.RecognitionResult recognitionResult)
        {
            this.Dispatcher.Invoke(new OnPerformVoiceCommand(PerformVoiceCommand), recognitionResult.Text);
        }

        #endregion

       
        internal void DoNavigateCommand(Nui.NavigationEngine.NuiNavigator.SkeletonsStateFlags flags)
        {
           


           
        }

        private void OnHandEnterControl(object sender, EventArgs e)
        {
          //  nuilessmood = true;
        }

        private void OnHandExitControl(object sender, EventArgs e)
        {
            nuilessmood = false;
            RefLocation = null;
        }



        
    }
       

}
